import { Editor } from '../editor'
import { Operation } from './operation'
import { DeleteTextOperation } from './delete_text_operation'

export class InsertTextOperation implements Operation {
  spacers_
  insertIndex
  constructor(spacers: string, insertIndex: number) {
    this.spacers_ = spacers
    this.insertIndex = insertIndex
  }
  getSpacers(): string {
    return this.spacers_
  }
  setSpacers(spacers: string) {
    this.spacers_ = spacers
  }
  apply(editor: Editor): void {
    editor.getTextModel().insert(this.insertIndex, this.spacers_)
  }
  reverse() {
    return new DeleteTextOperation(this.insertIndex, this.insertIndex + this.spacers_.length)
  }
}

